Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3팀 김진현][Chapter 1-1] 프레임워크 없이 SPA 만들기 #15

Closed
wants to merge 12 commits into from

Conversation

jinhyeon0810
Copy link

@jinhyeon0810 jinhyeon0810 commented Sep 24, 2024

과제 체크포인트

기본과제

1) 라우팅 구현:

  • History API를 사용하여 SPA 라우터 구현
    • '/' (홈 페이지)
    • '/profile' (프로필 페이지)
    • '/404' (Not Found 페이지)
  • 각 라우트에 해당하는 컴포넌트 렌더링 함수 작성
  • 네비게이션 이벤트 처리 (링크 클릭 시 페이지 전환)

2) 사용자 관리 기능:

  • LocalStorage를 사용한 간단한 사용자 데이터 관리
    • 사용자 정보 저장 (이름, 간단한 소개)
    • 로그인 상태 관리 (로그인/로그아웃 토글)
  • 로그인 폼 구현
    • 사용자 이름 입력 및 검증
    • 로그인 버튼 클릭 시 LocalStorage에 사용자 정보 저장
  • 로그아웃 기능 구현
    • 로그아웃 버튼 클릭 시 LocalStorage에서 사용자 정보 제거

3) 프로필 페이지 구현:

  • 현재 로그인한 사용자의 정보 표시
    • 사용자 이름
    • 간단한 소개
  • 프로필 수정 기능
    • 사용자 소개 텍스트 수정 가능
    • 수정된 정보 LocalStorage에 저장

4) 컴포넌트 기반 구조 설계:

  • 재사용 가능한 컴포넌트 작성
    • Header 컴포넌트
    • Footer 컴포넌트
  • 페이지별 컴포넌트 작성
    • HomePage 컴포넌트
    • ProfilePage 컴포넌트
    • NotFoundPage 컴포넌트

5) 상태 관리 초기 구현:

  • 간단한 상태 관리 시스템 설계
    • 전역 상태 객체 생성 (예: 현재 로그인한 사용자 정보)
  • 상태 변경 함수 구현
    • 상태 업데이트 시 관련 컴포넌트 리렌더링

6) 이벤트 처리 및 DOM 조작:

  • 사용자 입력 처리 (로그인 폼, 프로필 수정 등)
  • 동적 컨텐츠 렌더링 (사용자 정보 표시, 페이지 전환 등)

7) 기본적인 에러 처리:

  • 잘못된 라우트 접근 시 404 페이지로 리다이렉션
  • 로그인 실패 시 에러 메시지 표시

심화과제

1) 고급 라우팅

  • 라우트 가드 구현
    • 로그인 상태에 따른 접근 제어
    • 비로그인 사용자의 특정 페이지 접근 시 로그인 페이지로 리다이렉션

2) 고급 이벤트 처리

  • 이벤트 위임 활용

리뷰 받고 싶은 내용

궁금한 점

과제를 수행하면서 느낀점

과제 시작 전 생각

과제 제출 후 생각

기타

과제 난이도

@jinhyeon0810 jinhyeon0810 changed the title [3팀 김진현][Chapter 1-1] 프레임워크 없이 SPA 만들기 (기본과제) [3팀 김진현][Chapter 1-1] 프레임워크 없이 SPA 만들기 Sep 24, 2024
Copy link

@hty0525 hty0525 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

라우터 가드를 페이지가 아닌 라우터 자체에서 하는 것도 괜찮아 보이는데 어떻게 생각하시나요,,!!

</li>
</ul>
</nav>`;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nav를 객체 배열로 만들어서 관리하는거 혹시 어떠신가요,,,!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map으로 반복문 돌리는거 말씀하시는거죠? ㅎㅎ 유지보수 측면에서 좋은 방법인거같습니다


const profileLinkClass =
currentPath === "/profile" ? "text-blue-600" : "text-gray-600";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

경로부분이 하드코딩 되어있는데 상수로 뺀다면 더 편하게 관리할 수 있을거같아요!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵!ㅎㅎ 리뷰감사합니다 ㅎㅎ

export const user = new User();
export function isLoggedIn() {
return user?.preferences?.username?.length > 0;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export �const isLoggedIn =() => user?.preferences?.username?.length > 0;

이런식으로 축약해서 사용할 수도 있을 것 같습니다~!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호 넵 화살표함수로 작성하니 더 깔끔해보여 좋은거같습니다!

errorBoundary.id = "error-boundary";
errorBoundary.textContent = `오류 발생! ${event.message}`;
document.body.appendChild(errorBoundary);
});
Copy link

@rami0617 rami0617 Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appendChild를 해주게 되면 repaint나 reflow가 일어날 수 있습니다. 미리 error-boundary를 만들고 에러가 발생하면 보여주는건 어떨까요~?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 이부분 생각도못했네요 감사합니다👍

export function HomePage() {
let html;
html = ` <div class="bg-gray-100 min-h-screen flex justify-center">
<div class="max-w-md w-full">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

html을 선언하고 한번만 할당하고 있어 const html = `` 이런식으로 바꿔 보는건 어떨까요~?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그러네요 ㅎㅎ 피드백 감사합니다!

@JunilHwang JunilHwang closed this Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants